package com.dyh.quickdemo.reactor;


import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import reactor.core.Disposable;
import reactor.core.publisher.Flux;

import java.time.Duration;

@Slf4j
public class TestDispost {

    @Test
    public void test() throws InterruptedException {

        Flux<Long> source = Flux.interval(Duration.ofMillis(50));

        Disposable disposable  = source.subscribe(data->log.info("data={}",data));


        Thread.sleep(200);

        /*200 ms 后取消订阅 50s一次 大概会通过4个*/
        disposable.dispose();
    }

    public static Flux<Long> flux;

    @Test
    public void test2(){

    }
}
